import 'package:car_map/mode/byrent_car_model.dart';
import 'package:car_map/widget/widget_byrent_car_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

///汽车凭租
class ByrentCarPage extends StatefulWidget{
  @override
  _byrentCarState createState() =>_byrentCarState();

}

class _byrentCarState extends State<ByrentCarPage>{
  
  List<ByrentCarModel> byrentList;
  ScrollController _scrollController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _scrollController=new ScrollController();
    getByrentList();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _scrollController.dispose();
  }
  
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text('汽车凭租'),
      ),
      body: Container(
        child:StaggeredGridView.countBuilder(
          controller: _scrollController,
            itemCount: byrentList.length,
            crossAxisCount: 4,
            itemBuilder: (context,index){
            return WidgetByrentCarItem(byrentCarModel: byrentList[index],);
            },
            staggeredTileBuilder: (index)=> StaggeredTile.fit(2),
        ),
      ),
    );
  }


//  GridView.builder(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//  crossAxisCount: 2,
//  childAspectRatio: 2 /1.9,
//  ), itemBuilder: (BuildContext context,int index){
//  return WidgetByrentCarItem(byrentCarModel: byrentList[index],);
//  },itemCount: byrentList.length,),

  List<ByrentCarModel> getByrentList(){
    byrentList=new List();

    byrentList.add(new ByrentCarModel(urlPath: 'http://www.chinacar.com.cn/resources/ueditor/image/20170907/77d394ede9a80fa6b5218feb6d2d14af.jpg',
    carName: '帕萨特经典款',money: 450,Hmoney: 30,Kmoney: 3,address: '科技四路'));

    byrentList.add(new ByrentCarModel(urlPath: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573098479434&di=8cfa7693dec78065d5576cdfe5c440e7&imgtype=0&src=http%3A%2F%2F04img.mopimg.cn%2Fmobile%2F20171227%2F20171227231333_4586ed482363d24c11e9a111da4b0bb6_2.jpeg',
        carName: '别克君威',money: 500,Hmoney: 30,Kmoney: 3,address: '科技三路'));

    byrentList.add(new ByrentCarModel(urlPath: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573098526953&di=dcae323385952cc4af773db3a245f5a1&imgtype=0&src=http%3A%2F%2F01.imgmini.eastday.com%2Fmobile%2F20180204%2F20180204225746_3eeaf0340de9e3cea104588a07ae117c_3.jpeg',
        carName: '一汽奥迪A6L',money: 800,Hmoney: 60,Kmoney: 6,address: '科技四路'));

    byrentList.add(new ByrentCarModel(urlPath: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573098564940&di=6ba63dca57095445b1f754d01250b881&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F1806600055259f69efbfcdd707e0b6ca83b18e66e90b9-y3NLSv_fw658',
        carName: '帕萨特经典款',money: 450,Hmoney: 30,Kmoney: 3,address: '科技二路'));

    byrentList.add(new ByrentCarModel(urlPath: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573098585135&di=6a312d496b9393abd33b923d9ff2745b&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180126%2F232f7ba1b98f4c5684f8857e951f3c83.jpeg',
        carName: '宝马750',money: 2000,Hmoney: 100,Kmoney: 10,address: '科技路'));

    byrentList.add(new ByrentCarModel(urlPath: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573098615062&di=4052178aa5dcab037b53693d0dafc37a&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20190118%2F6e4e11c13b254816a8640aa9526fba51.jpeg',
        carName: '梅赛德斯奔驰S500',money: 2000,Hmoney: 100,Kmoney: 10,address: '科技九路'));
  }
}